package com.hqyj.controller;



import com.hqyj.entity.Order;
import com.hqyj.entity.ResultVo;
import com.hqyj.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author rock
 * @since 2022-09-20
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    IOrderService orderService;

    /**
     * 查询所以订单
     * @param order
     * @return
     */
    @GetMapping("/queryAllOrder")
    public ResultVo queryAllOrder(Order order){
        System.out.println(orderService.queryAllOrder(order));
        return orderService.queryAllOrder(order);
    }

    /**
     * 根据用户查询订单
     * @param order
     * @return
     */

    @GetMapping("/queryOrderByUser")
    public ResultVo queryOrderByUser(Order order){
     return orderService.queryOrderByUser(order);
    }

    /**
     * 添加订单
     * @param order
     * @return
     */

    @PostMapping("/addOrder")
    public ResultVo addOrder(Order order){
        return orderService.addOrder(order);
    }

    /**
     * 修改订单
     * @param order
     * @return
     */
    @GetMapping("/updateOrder")
    public ResultVo updateOrder(Order order){
        return orderService.updateOrder(order);
    }

    /**
     * 删除订单
     * @param oid
     * @return
     */
    @GetMapping("/delOrderByOid")
    public ResultVo delOrderByOid(int oid){
        return orderService.delOrderByOid(oid);
    }

    /**
     * 查询订单的详细信息
     * @param oid
     * @return
     */
    @GetMapping("/showOrder")
    public ResultVo showOrder(int oid){
        return orderService.showOrder(oid);
    }

    /**
     * 统计订单总价
     * @param order
     * @return
     */
    @GetMapping("/totalOrder")
    public ResultVo totalOrder(Order order){
        return orderService.totalOrder(order);
    }





}

